package com.example.myapplication1;

import android.app.AlertDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.example.myapplication1.utils.PreferenceManager;

public class ProfileFragment extends Fragment {
    private PreferenceManager preferenceManager;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_profile, container, false);
        preferenceManager = new PreferenceManager(requireContext());





        setupUserInfo(view);
        setupClickListeners(view);

        return view;
    }

    private void setupUserInfo(View view) {
        TextView usernameText = view.findViewById(R.id.username_text);
        usernameText.setText(preferenceManager.getUsername());
    }

    private void setupClickListeners(View view) {
        // 紧急求助点击事件
        view.findViewById(R.id.emergency_help).setOnClickListener(v -> {
            new AlertDialog.Builder(requireContext())
                .setMessage("请尽快联系工作人员：\n\n13700000001\n13700000002\n13700000003")
                .setPositiveButton("确定", null)
                .show();
        });
    }
} 